﻿using System;
using System.Collections.Generic;
using System.Text;
using NFinal.Action;

namespace NFinal
{
    public class ContentResult: ActionResult
    {
        public ContentResult(string content,string contentType)
        {
            this.Content = content;
            this.ContentType = "text/html; charset=utf-8;";
        }
        public string Content { get; set; }
        public override void ExecuteResult<TContext, TRequest>(AbstractAction<TContext, TRequest> context)
        {
            context.SetResponseHeader(Constant.HeaderContentType, this.ContentType);
            context.Write(this.Content);
            if (this.ContentType?.Length > 0)
            {
                context.contentType = this.ContentType;
            }
            context.Close();
        }
    }
}
